package 多态.instrumentExample;

public class StaticExample {
	public static void main(String[] args) {
		Super aSuper = new Sub();
		//这里的向上转型，得到的是super的field
		System.out.println(aSuper.getField()); //1
		//这里直接访问，得到的是sub的field
		System.out.println(aSuper.field); //0
		Sub sub = new Sub();
		System.out.println(sub.getField()); //1
		System.out.println(sub.field); //1
		System.out.println(sub.getSuperField()); //0
	}
}

class Super {
	public int field = 0;

	public int getField() {
		return field;
	}
}

class Sub extends Super {
	public int field = 1;

	public int getField() {
		return field;
	}

	public int getSuperField() {
		return super.field;
	}
}
